#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：Employment_class 
@File    ：02_re模块高级用法.py
@IDE     ：PyCharm 
@Author  ：XiaoDengYa
@Date    ：2021/7/9/009 11:17 
"""

# search 需求匹配出文章阅读次数
import re

"""
ret = re.search(r"\d+", "阅读次数为 999").group()
print(ret)

# findall 需求：统计出python、c、c++响应文章阅读的次数
ret = re.findall(r"\d+", "python	=	9999,	c	=	7890,	c++	=	12345")
print(ret)

# sub	将匹配到的数据进⾏替换 需求：将匹配到的阅读次数加1

ret = re.sub(r"\d+", '998', "python	=	997")
print(ret)
"""
# ret = """
# <html lang="en">
#     <head>
#         <meta charset="UTF-8" />
#         <meta name="viewport" content="width=device-width, initial-scale=1.0" />
#         <title>Document</title>
#     </head>
#     <body>
#         <input type="button" value="点我点我" onclick="alert('千古壹号的方式1')" />
#     </body>
# </html>
# """
#
# res = re.search("value+\W{2}.{4}\W",ret).group()
# print(res)

# 从下⾯的字符串中取出⽂本
ret = """
<div>
<p>岗位职责：</p> 
<p>完成推荐算法、数据统计、接⼝、后台等服务器端相关⼯作</p> 
<p><br></p> 
<p>必备要求：</p> 
<p>良好的⾃我驱动⼒和职业素养，⼯作积极主动、结果导向</p> 
<p>&nbsp;<br></p> <p>技术要求：</p> 
<p>1、⼀年以上	Python	开发经验，掌握⾯向对象分析和设计，了解设计模式</p > 
<p>2、掌握HTTP协议，熟悉MVC、MVVM等概念以及相关WEB开发框架</p> 
<p>3、掌握关系数据库开发设计，掌握	SQL，熟练使⽤	MySQL/PostgreSQL	中 的⼀种<br></p> 
<p>4、掌握NoSQL、MQ，熟练使⽤对应技术解决⽅案</p>
<p>5、熟悉	Javascript/CSS/HTML5，JQuery、React、Vue.js</p> 
<p>&nbsp;<br></p> <p>加分项：</p> 
<p>⼤数据，数理统计，机器学习，sklearn，⾼性能，⼤并发。</p>
<div>
"""

# re.search("<(?P<str1>\w)>.*</(?P=str1)>", ret).group()
#
# for i in ret.splitlines():
#     try:
#         print(re.search("<(?P<str1>\w)>.*</(?P=str1)>", i).group())
#     except:
#         pass


# # split	根据匹配进⾏切割字符串，并返回⼀个列表 根据 :或者空格进行切割
# ret = re.split(r":|	", "info:xiaoZhang	33	shandong")
# print(ret)


"""
贪婪&非贪婪
    python数量词默认是贪婪的（在少数语言中也可能默认非贪婪）总是尝试匹配尽可能多的字符
    非贪婪相反，尝试匹配尽可能少的字符
"""
# 在"*","?","+","{m,n}"后⾯加上？，使贪婪变成⾮贪婪

# s = "This	is	a	number	55555234-235-22-423"
# r = re.match(".+(\d+-\d+-\d+-\d+)", s).group(1)
# print(r)
# r = re.match(".+?(\d+-\d+-\d+-\d+)", s).group(1)
# print(r)


# url = """<img	data-original="https://rpic.douyucdn.cn/appCovers/2016/11/13/1213973_201611131917_small.jpg"	src="https://rpic.douyuc dn.cn/appCovers/2016/11/13/1213973_201611131917_small.jpg"	st yle="display:	inline;">
# """
# img_url = re.search("(https)?://.*_[a-z]{5}.[a-z]{3}",url).group()
# print(img_url)

#http://3995503.com/class/class09/news_show.asp?id=14
# http://lib.wzmc.edu.cn/news/onews.asp?id=769
# http://www.zy-ls.com/alfx.asp?newsid=377&id=6
# http://www.fincm.com/newslist.asp?id=415
# ret = """
# http://www.interoem.com/messageinfo.asp?id=35
# """
# # res = re.search(r"\w*\W[a-z]{3}\Wid\W\d*",ret)
# res = re.sub(r"\w*\W[a-z]{3}\Wid\W\d*", "", ret)
# print(res)

# ret = "http://www.zy-ls.com/alfx.asp?newsid=377&id=6"
# res = re.sub(r"[a-z]{4}\W[a-z]{3}\W.*\d","", ret)
# print(res)
ret = "http://lib.wzmc.edu.cn/news/onews.asp?id=769"
res = re.search(r"news\W\w.*\d*", ret).group()
print(res)